﻿using System;
using System.Collections;
using System.Linq;
using System.Windows.Forms;
using System.Net;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Text;




namespace InfraTools
{
    public class Glpi
    {

        

        //Constructors For Glpi Class 
        public Glpi()
        {
            isconnected = false;
        }

        public Glpi(String RestWsUrl, String GlpiUsr, String GlpiPass)
        {
            restWsUrl = RestWsUrl;
            glpiPass = GlpiPass;
            glpiUsr = GlpiUsr;
            isconnected = false;

        }

        // Public Vars 
        public string restWsUrl { get; set; }
        public string glpiUsr { get; set; }
        public string glpiPass { get; set; }
        public string sessionID;
        public int entity { get; set; } 
        private bool isconnected;

        //Private Vars 

        //Methods


        public bool isConnected(bool Verbose)
        {
            if (isconnected)
            {
                return true;
            }
            else
            {
                if (Verbose)
                {
                    MessageBox.Show("Please login !");
                }

                return false;

            }
        }

        public Glpiuser doLogin()
        {
            Glpiuser _loggedusr = new Glpiuser();
            try
            {
                WebClient serviceRequest = new WebClient();
                string queryString = String.Format("?method=glpi.doLogin&login_name={0}&login_password={1}", glpiUsr, glpiPass);
                string _url = restWsUrl + queryString;

                if (CheckRequest(_url).isOK)
                {
                    string response = serviceRequest.DownloadString(new Uri(_url));
                    _loggedusr = JsonConvert.DeserializeObject<Glpiuser>(response);
                    if (_loggedusr.name == glpiUsr)
                    {
                        sessionID = _loggedusr.session;
                        isconnected = true;
                        SetEntity(entity);
                        return _loggedusr;
                    }
                }


                isconnected = false;
                return _loggedusr;




            }
            catch (Exception)
            {

                return _loggedusr;


            }

        }

        public Boolean doLogout()
        {

            try
            {
                WebClient serviceRequest = new WebClient();
                string queryString = String.Format("?method=glpi.doLogout&session={0}", sessionID);
                string _url = restWsUrl + queryString;
                if (CheckRequest(_url).isOK)
                {
                    string response = serviceRequest.DownloadString(new Uri(_url));
                    JObject _logoutrslt = JObject.Parse(response);
                    if (_logoutrslt["message"] != null)
                    {
                        isconnected = false;
                        sessionID = null;
                        return true;
                    }
                    return false;
                }



                return false;

            }
            catch (Exception)
            {
                return false;


            }
        }

        public int SetEntity(int entityid)
        {

            try
            {
                WebClient serviceRequest = new WebClient();
                string queryString = String.Format("?method=glpi.setMyEntity&entity={0}&session={1}",entityid, sessionID);
                string _url = restWsUrl + queryString;
                if (CheckRequest(_url).isOK)
                {
                    string response = serviceRequest.DownloadString(new Uri(_url));
                    JObject entityrslt = JObject.Parse(response);
                    if (entityrslt["id"] != null)
                    {
                        entityid = (int)entityrslt["id"];
                        return entityid;
                    }
                    return 0;
                }



                return 0;

            }
            catch (Exception)
            {
                return 0;


            }
        }



        public Glpiuser GetUser(string _SamAccountName)
        {
            Glpiuser _usr = new Glpiuser();
            _usr.id = 0;
            _usr.name = "not found";
            try
            {
                if (this.isconnected)
                {
                    WebClient serviceRequest = new WebClient();
                    string queryString = String.Format("?method=glpi.listUsers&session={0}&login={1}", sessionID, _SamAccountName);
                    string _url = restWsUrl + queryString;
                    if (CheckRequest(_url).isOK)
                    {
                        string response = serviceRequest.DownloadString(new Uri(_url));
                        List<Glpiuser> Users = JsonConvert.DeserializeObject<List<Glpiuser>>(response);
                        if (Users[0].name != null)
                        {

                            return Users[0];

                        }

                    }


                }
                return _usr;

            }
            catch (Exception)
            {
                return _usr;


            }

        }

        public List<Ticket> GetTicketsbyuser(int userID)
        {

            Ticket ticket = new Ticket();
            List<Ticket> tempTicketlst = new List<Ticket>();
            List<Ticket> Ticketlst = new List<Ticket>();

            try
            {
                if (isconnected)
                {

                    WebClient serviceRequest = new WebClient();
                    string queryString = String.Format("?method=glpi.listTickets&limit=99999&id2name=1&approval=all&recipient={0}&session={1}", userID, sessionID);
                    string _url = restWsUrl + queryString;
                    if (CheckRequest(_url).isOK)
                    {
                        string response = serviceRequest.DownloadString(new Uri(_url));
                        tempTicketlst = JsonConvert.DeserializeObject<List<Ticket>>(response);

                        foreach (Ticket T in tempTicketlst)
                        {
                            Ticketlst.Add(GetTicket(T.id));

                        }
                        return Ticketlst;


                    }


                }

                Ticketlst.Add(ticket);


                return Ticketlst;


            }
            catch (Exception)
            {
                Ticketlst.Add(ticket);
                return Ticketlst;

            }



        }

        public Ticket GetTicket(string ticketID)
        {

            Ticket ticket = new Ticket();

            try
            {
                if (isconnected)
                {
                    WebClient serviceRequest = new WebClient();
                    string queryString = String.Format("?method=glpi.getTicket&id2name=1&ticket={0}&session={1}", ticketID, sessionID);
                    string _url = restWsUrl + queryString;
                    if (CheckRequest(_url).isOK)
                    {
                        string response = serviceRequest.DownloadString(new Uri(_url));
                        ticket = JsonConvert.DeserializeObject<Ticket>(response);


                        return ticket;


                    }
                }

                return ticket;

            }
            catch (Exception)
            {



                return ticket;
            }



        }

        //create ticket 

        public Ticket CreateTicket(NewTicket ticketitem)
        {

            Ticket ticket = new Ticket();


            try
            {
                WebClient serviceRequest = new WebClient();
                string pattern = @"\b=&/";
                if (isconnected)
                {
                    ticketitem.ToString();

                    string queryString = String.Format("?method=glpi.createTicket&title={0}&content={1}&urgency={2}&type={3}&entity={4}&user={5}&group={6}&requester={7}&victim={8}&observer={9}&itemtype={10}&item={11}&source={12}&category={13}&user_email={14}&user_email_notification={15}&session={16}", ticketitem.title, ticketitem.content, ticketitem.urgency, ticketitem.type, ticketitem.entity, ticketitem.user, ticketitem.group, ticketitem.requester, ticketitem.victim, ticketitem.observer, ticketitem.itemtype, ticketitem.item, ticketitem.source, ticketitem.category, ticketitem.user_email, ticketitem.use_email_notification, sessionID);


                    string _url0 = restWsUrl + queryString;
                    Regex rgx = new Regex(pattern);
                    string _url = rgx.Replace(_url0, "&");


                    MessageBox.Show(String.Format("Original String:    '{0}' \n Replacement String: '{1}' ", _url0, _url));
                    if (CheckRequest(_url).isOK)
                    {
                        string response = serviceRequest.DownloadString(new Uri(_url));
                        ticket = JsonConvert.DeserializeObject<Ticket>(response);


                        return ticket;


                    }



                }


                return ticket;

            }
            catch (Exception)
            {
                return ticket;

            }



        }

        //get Dropdown Cmb Values

        public List<CmbObject> getCmbValues(string dropdownVal)
        {

            CmbObject cmb = new CmbObject();
            List<CmbObject> tempcmb = new List<CmbObject>();
            List<CmbObject> Cmblst = new List<CmbObject>();

            try
            {
                if (isconnected)
                {

                    WebClient serviceRequest = new WebClient();
                    string queryString = String.Format("?method=glpi.listDropdownValues&limit=9999&dropdown={0}&session={1}", dropdownVal, sessionID);
                    string _url = restWsUrl + queryString;
                    if (CheckRequest(_url).isOK)
                    {
                        string response = serviceRequest.DownloadString(new Uri(_url));
                        Cmblst = JsonConvert.DeserializeObject<List<CmbObject>>(response);



                        return Cmblst;


                    }


                }

                Cmblst.Add(cmb);


                return Cmblst;


            }
            catch (Exception)
            {

                return Cmblst;

            }



        }
        //conversion tools for dropdown menus 

        public int CmbName2Id(List<CmbObject> liste, string name)
        {
            return liste.Find(delegate(CmbObject p) { return p.Name == name; }).Id;

        }

        public string CmbId2Name(List<CmbObject> liste, int id)
        {
            return liste.Find(delegate(CmbObject p) { return p.Id == id; }).Name;

        }

        //create GLPI Object 
        public string CreateObject(List<Object> Objectitem, string objectype)
        {

            try
            {
                if (isconnected)
                {

                    string field = JsonConvert.SerializeObject(Objectitem);

                    field = "{\"" + objectype + "\":" + field + "}";
                    string queryString = String.Format("?method=glpi.createObjects&session={0}&fields={1}", sessionID, field);
                    string _url = restWsUrl + queryString;
                    return CheckRequest(_url).response;

                }
                else
                {
                    return string.Empty;
                }
            }
            catch (Exception)
            {
                return string.Empty;
            }

        }

        //Update GLPI Object 
        public string UpdateObject(List<Object> Objectitem, string objectype)
        {

            try
            {
                if (isconnected)
                {

                    string field = JsonConvert.SerializeObject(Objectitem);

                    field = "{\"" + objectype + "\":" + field + "}";
                    string queryString = String.Format("?method=glpi.updateObjects&session={0}&fields={1}", sessionID, field);
                    string _url = restWsUrl + queryString;
                    return CheckRequest(_url).response;

                }
                else
                {
                    return string.Empty;
                }
            }
            catch (Exception)
            {
                return string.Empty;
            }

        }

        //Link GLPI Objects 
        public string LinkObjects(string itemtype1, int itemID1, string itemtype2, int itemID2)
        {

            try
            {
                if (isconnected)
                {


                    string field = "[{\"from_item\":{\"itemtype\":\"" + itemtype1 + "\",\"id\":\"" + itemID1.ToString() + "\"},\"to_item\":{\"itemtype\":\"" + itemtype2 + "\",\"id\":\"" + itemID2.ToString() + "\"}}]";
                    string queryString = String.Format("?method=glpi.linkObjects&session={0}&fields={1}", sessionID, field);
                    string _url = restWsUrl + queryString;
                    return CheckRequest(_url).response;

                }
                else
                {
                    return string.Empty;
                }
            }
            catch (Exception)
            {
                return string.Empty;
            }

        }

        public GlpiComputer GetComputerBySerial(string Serial)
        {

            GlpiComputer PC = new GlpiComputer();
            List<GlpiComputer> PCS = new List<GlpiComputer>();
            List<GlpiComputer> PClst = new List<GlpiComputer>();

            try
            {
                if (isconnected)
                {

                    WebClient serviceRequest = new WebClient();
                    string queryString = String.Format("?method=glpi.listObjects&limit=99999&itemtype=Computer&with_contract=1&serial={0}&show_name=1&session={1}", Serial, sessionID);
                    string _url = restWsUrl + queryString;
                    if (CheckRequest(_url).isOK)
                    {
                        string response = serviceRequest.DownloadString(new Uri(_url));
                        PClst = JsonConvert.DeserializeObject<List<GlpiComputer>>(response);

                        foreach (GlpiComputer pc in PClst)
                        {
                            PC = GetComputer(pc.id);
                            if (PC.Contract[0].id != null)
                            {
                                return PC;
                            }
                            else
                            {

                            }

                        }

                        return PC;


                    }


                }




                return PC;


            }
            catch (Exception)
            {


                return PC;

            }



        }

        public GlpiComputer GetComputer(string ObjectID)
        {


            try
            {
                if (isconnected)
                {
                    WebClient serviceRequest = new WebClient();
                    string queryString = String.Format("?method=glpi.getObject&with_contract=1&show_name=1&id={0}&session={1}&itemtype=Computer", ObjectID, sessionID);
                    string _url = restWsUrl + queryString;
                    if (CheckRequest(_url).isOK)
                    {
                        string response = serviceRequest.DownloadString(new Uri(_url));
                        return JsonConvert.DeserializeObject<GlpiComputer>(response);

                    }
                    return null;
                }

                return null;
            }
            catch (Exception)
            {
                return null;
            }
        }

        public GlpiMonitor GetMonitorBySerial(string Serial)
        {

            GlpiMonitor Monitor = new GlpiMonitor();
            List<GlpiMonitor> Minitors = new List<GlpiMonitor>();
            List<GlpiMonitor> Monitorslst = new List<GlpiMonitor>();

            try
            {
                if (isconnected)
                {

                    WebClient serviceRequest = new WebClient();
                    string queryString = String.Format("?method=glpi.listObjects&limit=99999&itemtype=Monitor&with_contract=1&serial={0}&show_name=1&session={1}", Serial, sessionID);
                    string _url = restWsUrl + queryString;
                    if (CheckRequest(_url).isOK)
                    {
                        string response = serviceRequest.DownloadString(new Uri(_url));
                        Monitorslst = JsonConvert.DeserializeObject<List<GlpiMonitor>>(response);

                        foreach (GlpiMonitor mon in Monitorslst)
                        {
                            Monitor = GetMonitor(mon.id);
                            if (mon.Contract[0].id != null)
                            {
                                return mon;
                            }


                        }

                        return Monitor;


                    }


                }




                return Monitor;


            }
            catch (Exception)
            {


                return Monitor;

            }



        }

        public GlpiMonitor GetMonitor(string ObjectID)
        {


            try
            {
                if (isconnected)
                {
                    WebClient serviceRequest = new WebClient();
                    string queryString = String.Format("?method=glpi.getObject&with_contract=1&show_name=1&id={0}&session={1}&itemtype=Monitor", ObjectID, sessionID);
                    string _url = restWsUrl + queryString;
                    if (CheckRequest(_url).isOK)
                    {
                        string response = serviceRequest.DownloadString(new Uri(_url));
                        return JsonConvert.DeserializeObject<GlpiMonitor>(response);

                    }
                    return null;
                }

                return null;
            }
            catch (Exception)
            {
                return null;
            }
        }

        public ArrayList GetGlpiComputers(string namefilter)
        {

            ArrayList GlpiComputers = new ArrayList();
            List<GlpiComputer> PClst = new List<GlpiComputer>();

            try
            {
                if (isconnected)
                {

                    WebClient serviceRequest = new WebClient();
                    string queryString = String.Format("?method=glpi.listObjects&limit=99999&itemtype=Computer&session={0}&name={1}", sessionID, namefilter);
                    string _url = restWsUrl + queryString;
                    if (CheckRequest(_url).isOK)
                    {
                        string response = serviceRequest.DownloadString(new Uri(_url));
                        PClst = JsonConvert.DeserializeObject<List<GlpiComputer>>(response);

                        foreach (GlpiComputer pc in PClst)
                        {
                            GlpiComputers.Add(pc.name);
                        }
                        return GlpiComputers;
                    }

                }

                return GlpiComputers;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return GlpiComputers;
            }

        }
        //Validate Json returned Data  
        private Chkresponse CheckRequest(string _rqurl)
        {
            Chkresponse rsp = new Chkresponse();

            _rqurl = Regex.Replace(_rqurl, "[\"][a-zA-Z0-9_]*[\"]:null[ ]*[,]?", "");
            _rqurl = Regex.Replace(_rqurl, ",}", "}");

            try
            {
                WebClient serviceRequest = new WebClient();
                string response = serviceRequest.DownloadString(new Uri(_rqurl));
                if (response.Contains("faultCode"))
                {
                    GlpiError error = JsonConvert.DeserializeObject<GlpiError>(response);
                    JObject _parsedrsp = JObject.Parse(response);

                    if (error.faultCode != 0)
                    {


                        throw new Exception("Error N°:" + _parsedrsp["faultCode"].ToString() + " Description: " + _parsedrsp["faultString"].ToString());

                    }
                }
                rsp.response = response;
                rsp.isOK = true;


                return rsp;


            }
            catch (Exception e)
            {


                MessageBox.Show(e.Message);
                rsp.isOK = false;
                rsp.response = e.Message;
                return rsp;
            }


        }

    //    public List<CmbObject> GetTemplatescmb(string Type)
    //    {

    //                    List<GlpiComputer> PClst = new List<GlpiComputer>();

    //        try
    //        {
    //            if (isconnected)
    //            {

                    
    //                List<CmbObject> cmblst = new List<CmbObject>();
    //                string queryString = String.Format("?method=glpi.listObjects&limit=99999&itemtype={0}&show_name=1&session={1}", Type, sessionID);
    //                string _url = restWsUrl + queryString;
    //                if (CheckRequest(_url).isOK)
    //                {
    //                    string response = serviceRequest.DownloadString(new Uri(_url));
                        
    //                    foreach (GlpiComputer item in JsonConvert.DeserializeObject<List<GlpiComputer>>(response))
    //                    {
    //                        if (Type == "Computers")
    //                        {
    //                           this.GetComputer(item.id.ToString).
    //                            cmblst.Add();
    //                        }
    //                        else if (Type == "Monitors")
    //                        {
                                
    //                        }
                            
    //                    }
    //                    return;

    //                }


    //            }

                


    //            return PClst;


    //        }
    //        catch (Exception)
    //        {

               
    //            return PClst;

    //        }
                
    //}

    }
        //Container Classes

        public class Glpiuser
        {
            public int id;
            public string name;
            public string realname;
            public string firstname;
            public string session;
        }

        public class GlpiError
        {
            public int faultCode;
            public string faultString;
        }

        public class Requester
        {
            public string id { get; set; }
            public string name;

        }

        public class Observer
        {
            public string id { get; set; }
            public string name;
        }

        public class Assign
        {
            public string id { get; set; }
            public string name;
        }

        public class Users
        {
            public List<Requester> requester { get; set; }
            public List<Observer> observer { get; set; }
            public List<Assign> assign { get; set; }
        }

        public class Groups
        {
            public List<Requester> requester { get; set; }
            public List<Observer> observer { get; set; }
            public List<Assign> assign { get; set; }
        }

        public class Followup
        {
            public string id { get; set; }
            public string tickets_id { get; set; }
            public string date { get; set; }
            public string users_id { get; set; }
            public string content { get; set; }
            public string is_private { get; set; }
            public string requesttypes_id { get; set; }
        }

        public class Event
        {
            public bool display_history { get; set; }
            public string id { get; set; }
            public string date_mod { get; set; }
            public string user_name { get; set; }
            public string field { get; set; }
            public string change { get; set; }
            public string datatype { get; set; }
        }

        public class Validation
        {
            public string id { get; set; }
            public string entities_id { get; set; }
            public string users_id { get; set; }
            public string tickets_id { get; set; }
            public string users_id_validate { get; set; }
            public string comment_submission { get; set; }
            public string comment_validation { get; set; }
            public string status { get; set; }
            public string submission_date { get; set; }
            public string validation_date { get; set; }
            public string users_name { get; set; }
            public string users_name_validate { get; set; }
            public string status_name { get; set; }
        }

        public class Ticket
        {
            public string id { get; set; }
            public string entities_id { get; set; }
            public string name { get; set; }
            public string requester { get; set; }
            public string observer { get; set; }
            public string date { get; set; }
            public object closedate { get; set; }
            public object solvedate { get; set; }
            public string date_mod { get; set; }
            public string users_id_lastupdater { get; set; }
            public string status { get; set; }
            public string users_id_recipient { get; set; }
            public string requesttypes_id { get; set; }
            public string suppliers_id_assign { get; set; }
            public string itemtype { get; set; }
            public string items_id { get; set; }
            public string content { get; set; }
            public string urgency { get; set; }
            public string impact { get; set; }
            public string priority { get; set; }
            public string itilcategories_id { get; set; }
            public string type { get; set; }
            public string cost_time { get; set; }
            public string cost_fixed { get; set; }
            public string cost_material { get; set; }
            public string solutiontypes_id { get; set; }
            public string solution { get; set; }
            public string global_validation { get; set; }
            public string slas_id { get; set; }
            public string slalevels_id { get; set; }
            public object due_date { get; set; }
            public object begin_waiting_date { get; set; }
            public string sla_waiting_duration { get; set; }
            public string waiting_duration { get; set; }
            public string close_delay_stat { get; set; }
            public string solve_delay_stat { get; set; }
            public string takeintoaccount_delay_stat { get; set; }
            public string actiontime { get; set; }
            public string is_deleted { get; set; }
            public int slalevels_next_id { get; set; }
            public string slalevels_next_date { get; set; }
            public Users users { get; set; }
            public Groups groups { get; set; }
            public List<Followup> followups { get; set; }
            public List<object> tasks { get; set; }
            public List<object> documents { get; set; }
            public List<Event> events { get; set; }
            public List<Validation> validations { get; set; }
            public List<object> satisfaction { get; set; }
            public string itemtype_name { get; set; }
            public string items_name { get; set; }
            public string status_name { get; set; }
            public string urgency_name { get; set; }
            public string impact_name { get; set; }
            public string priority_name { get; set; }
            public string users_name_recipient { get; set; }
            public string entities_name { get; set; }
            public string suppliers_name_assign { get; set; }
            public string ticketcategories_name { get; set; }
            public string requesttypes_name { get; set; }
            public string solutiontypes_name { get; set; }
            public string slas_name { get; set; }
            public string slalevels_name { get; set; }


        }

        public class NewTicket
        {
            public string content { get; set; }
            public string title { get; set; }
            public string entity { get; set; }
            public string urgency { get; set; }
            public string category { get; set; }
            public string user { get; set; }
            public string requester { get; set; }
            public string observer { get; set; }
            public string group { get; set; }
            public string date { get; set; }
            public string type { get; set; }
            public string itemtype { get; set; }
            public string item { get; set; }
            public string source { get; set; }
            public string user_email { get; set; }
            public string use_email_notification { get; set; }
            public string victim { get; set; }


        }

        public class NewComputer
        {
            public string id { get; set; }
            public string entities_id { get; set; }
            public string name { get; set; }
            public string serial { get; set; }
            public string otherserial { get; set; }
            public string contact { get; set; }
            public string contact_num { get; set; }
            public string users_id_tech { get; set; }
            public string groups_id_tech { get; set; }
            public string comment { get; set; }
            public string date_mod { get; set; }
            public string operatingsystems_id { get; set; }
            public string operatingsystemversions_id { get; set; }
            public string operatingsystemservicepacks_id { get; set; }
            public string os_license_number { get; set; }
            public string os_licenseid { get; set; }
            public string autoupdatesystems_id { get; set; }
            public string locations_id { get; set; }
            public string domains_id { get; set; }
            public string networks_id { get; set; }
            public string computermodels_id { get; set; }
            public string computertypes_id { get; set; }
            public string is_template { get; set; }
            public string template_name { get; set; }
            public string manufacturers_id { get; set; }
            public string is_deleted { get; set; }
            public object notepad { get; set; }
            public string is_ocs_import { get; set; }
            public string users_id { get; set; }
            public string groups_id { get; set; }
            public string states_id { get; set; }
            public string ticket_tco { get; set; }
            public string uuid { get; set; }
        }

        public class contract
        {
            public string id { get; set; }
            public string entities_id { get; set; }
            public string is_recursive { get; set; }
            public string name { get; set; }
            public string num { get; set; }
            public string cost { get; set; }
            public string contracttypes_id { get; set; }
            public string begin_date { get; set; }
            public string duration { get; set; }
            public string notice { get; set; }
            public string periodicity { get; set; }
            public string billing { get; set; }
            public string comment { get; set; }
            public string accounting_number { get; set; }
            public string is_deleted { get; set; }
            public string week_begin_hour { get; set; }
            public string week_end_hour { get; set; }
            public string saturday_begin_hour { get; set; }
            public string saturday_end_hour { get; set; }
            public string use_saturday { get; set; }
            public string monday_begin_hour { get; set; }
            public string monday_end_hour { get; set; }
            public string use_monday { get; set; }
            public string max_links_allowed { get; set; }
            public object notepad { get; set; }
            public string alert { get; set; }
            public string renewal { get; set; }
            public object template_name { get; set; }
            public string is_template { get; set; }
            public string contracttypes_name { get; set; }
        }

        public class GlpiComputer
        {

            public GlpiComputer()
            {

            }


            public string name { get; set; }
            public string name_name { get; set; }
            public string id { get; set; }
            public string locations_id { get; set; }
            public string computertypes_id { get; set; }
            public string computertypes_name { get; set; }
            public string computermodels_id { get; set; }
            public string computermodels_name { get; set; }
            public string states_id { get; set; }
            public string states_name { get; set; }
            public string operatingsystems_id { get; set; }
            public string operatingsystems_name { get; set; }
            public string operatingsystemversions_id { get; set; }
            public string operatingsystemversions_name { get; set; }
            public string operatingsystemservicepacks_id { get; set; }
            public string operatingsystemservicepacks_name { get; set; }
            public string autoupdatesystems_id { get; set; }
            public string autoupdatesystems_name { get; set; }
            public string os_license_number { get; set; }
            public string os_licenseid { get; set; }
            public string uuid { get; set; }
            public string serial { get; set; }
            public string otherserial { get; set; }
            public string comment { get; set; }
            public string contact { get; set; }
            public string users_id { get; set; }
            public string users_name { get; set; }
            public string groups_id { get; set; }
            public string date_mod { get; set; }
            public string networks_id { get; set; }
            public string domains_id { get; set; }
            public string domains_name { get; set; }
            public string manufacturers_id { get; set; }
            public string manufacturers_name { get; set; }
            public string users_id_tech { get; set; }
            public string groups_id_tech { get; set; }
            public string entities_id { get; set; }
            public string entities_name { get; set; }
            public string is_ocs_import { get; set; }
            public string is_ocs_import_name { get; set; }
            public List<contract> Contract { get; set; }

        }

        public class GlpiMonitor
        {
            public string id { get; set; }
            public string locations_id { get; set; }
            public string monitortypes_id { get; set; }
            public string monitortypes_name { get; set; }
            public string monitormodels_id { get; set; }
            public string monitormodels_name { get; set; }
            public string states_id { get; set; }
            public string states_name { get; set; }
            public string serial { get; set; }
            public string users_id { get; set; }
            public string groups_id { get; set; }
            public string date_mod { get; set; }
            public string size { get; set; }
            public string have_micro { get; set; }
            public string have_micro_name { get; set; }
            public string have_speaker { get; set; }
            public string have_speaker_name { get; set; }
            public string have_subd { get; set; }
            public string have_subd_name { get; set; }
            public string have_bnc { get; set; }
            public string have_bnc_name { get; set; }
            public string have_dvi { get; set; }
            public string have_dvi_name { get; set; }
            public string have_pivot { get; set; }
            public string have_pivot_name { get; set; }
            public string have_hdmi { get; set; }
            public string have_hdmi_name { get; set; }
            public string have_displayport { get; set; }
            public string have_displayport_name { get; set; }
            public string manufacturers_id { get; set; }
            public string manufacturers_name { get; set; }
            public string users_id_tech { get; set; }
            public string users_name_tech { get; set; }
            public string groups_id_tech { get; set; }
            public string entities_id { get; set; }
            public string entities_name { get; set; }
            public string is_global { get; set; }
            public string is_global_name { get; set; }
            public List<contract> Contract { get; set; }
        }

        public class CmbObject
        {

            public CmbObject() { }

            public CmbObject(int id, string name)
            {
                Id = id;
                Name = name;

            }

            public CmbObject(int id, string name, string comment)
            {
                Id = id;
                Name = name;
                Comment = comment;

            }

            public int Id { get; set; }
            public string Name { get; set; }
            public string Comment { get; set; }


        }

        public class Chkresponse
        {

            public bool isOK { get; set; }
            public string response { get; set; }
        }

        public class infrafields
        {
            public bool Sel { get; set; }
            public string Mac { get; set; }
            public string Sccm_Collection { get; set; }
            public bool PC_Label { get; set; }

        }

    }


